<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta name="viewport" content="user-scalable=no, initial-scale=1.0, maximum-scale=1.0" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta name="format-detection" content="telephone=no">
		<title>${initParam.WxAppName}</title>
		<link rel="stylesheet" href="${pageContext.request.contextPath}/bettery/js/jquery.confirm/jquery.confirm.css">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/bettery/css/life.css?v=192">
		<link rel="stylesheet" href="${pageContext.request.contextPath}/bettery/css/lifeAddress.css">

		<script type="text/javascript" src="${pageContext.request.contextPath}/dewei/js/jquery.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/bettery/js/jquery.confirm/jquery.confirm.js"></script>
		<script src="${pageContext.request.contextPath}/bettery/js/jquery-ui-1.10.4.custom.min.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/bettery/js/template.js"></script>
		<script type="text/javascript">
		
		</script>
	</head>
	<body>
	<input type="hidden" value="${lat}" name='lat' id="hiddenbLat" />
	<input type="hidden" value="${lng}" name='lng' id="hiddenbLng" />
	
	<s:iterator value="ids" var="idss">
		<input type="hidden" value="${idss}" name='ids' />
	</s:iterator>
	<s:iterator value="buyNums" var="buyNum">
	    <input type="hidden" value="${buyNum}" name='buyNums' />
	</s:iterator>
	
	<div id="wrapBody" class="wx_wrap">
			<div style="" class="address_list" id="addressList">
				<div class="address" id="address_ul_list">
				</div>
				<div id="addressLink" class="address_list_link">
					<a style="" class="item item_new" href="javascript:void(0);" onclick="addAddress();"  id="addAddress">新增收货地址</a>
				</div>
	        </div>
	</div>
<script id="address_ul_list_data" type="text/html">
{{each list as value i}}
    <ul  {{if value.checked}}  class="selected" {{/if}}>
		<li onclick="changeCheckedAddr({{value.id}});">
			{{value.province}}{{value.city}}{{value.town}}{{value.address}}
		</li>
		<li onclick="changeCheckedAddr({{value.id}});">
			<strong>{{value.cname}}</strong> {{value.mobi}}
		</li>
		<li wxAddressId="{{value.id}}" onclick="addAddress({{value.id}})" class="edit">
			编辑
		</li>
	</ul>
	<p  class="act">
		<span class="del">删除</span>
	</p>
{{/each}}
</script>
<script type="text/javascript">
	var json=${json};
	$(function(){
		if(null!=json&&json.length>0)
		{
			var data={list:json};
			var html = template('address_ul_list_data', data);
			document.getElementById('address_ul_list').innerHTML = html;
		}
	});
</script>
<script type="text/javascript">
	function addAddress(id){
	    var lat=$("#hiddenbLat").val();
		var lng=$("#hiddenbLng").val();
		var fix="?lat="+lat+"&lng="+lng;
		if(id){
			fix=fix+"&id="+id;
		}
		$("input[name='ids']").each(function(){
			fix=fix+"&ids="+$(this).val();
		});
		$("input[name='buyNums']").each(function(){
			fix=fix+"&buyNums="+$(this).val();
		});
		this.location.href="editReceiptAddr.do"+fix;
	}
	function changeCheckedAddr(id){
		if(id){
			var lat=$("#hiddenbLat").val();
			var lng=$("#hiddenbLng").val();
			var fix="?lat="+lat+"&lng="+lng+"&id="+id;
			$("input[name='ids']").each(function(){
				fix=fix+"&ids="+$(this).val();
			});
			$("input[name='buyNums']").each(function(){
				fix=fix+"&buyNums="+$(this).val();
			});
			this.location.href="changeCheckedAddr.do"+fix;
		}
	}
</script>
	</body>
</html>